from typing import List, Any, Generator


def generator(n:int)->Generator[int, Any, None]:
    print("hahah")
    i = 1
    while i <= n:
        print("hahah1")
        yield i
        i += 1

gen = generator(5)    #! gen是一个生成器对象，而不是1
for val in gen:
    print(val)


# #! 生成器表达式: 不是创建一个元组，gen是一个僧撑起
# gen = (i**2 for i in range(1, 11))
# for val in gen:
#     print(val)
# print("=======================")


def sub_generator():
    yield 1
    yield 2
    yield 3
 
def main_generator():
    yield from sub_generator()
    yield 4
    yield 5
 
for num in main_generator():
    print(num)
